home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.19990422-19990725
/
000043_news@watsun.cc.columbia.edu _Fri May 7 20:17:18 1999.msg
< prev
next >
Wrap
Internet Message Format
|
2020-01-01
|
5KB
Return-Path: <news@watsun.cc.columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id UAA14147
for <kermit.misc@watsun.cc.columbia.edu>; Fri, 7 May 1999 20:17:18 -0400 (EDT)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id UAA25732
for kermit.misc@watsun.cc.columbia.edu; Fri, 7 May 1999 20:12:08 -0400 (EDT)
X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
Subject: Re: scripting against curses
Date: 8 May 1999 00:12:07 GMT
Organization: Columbia University
Message-ID: <7gvvgn$p41$1@newsmaster.cc.columbia.edu>
To: kermit.misc@watsun.cc.columbia.edu
In article <7gvsrc$no6$1@samba.rahul.net>, <dold@network.rahul.net> wrote:
: I haven't even tried yet, so maybe this will be simple ;-)
:
: I need to develop a script to replace some manual entries to the SMS-800
: database. I've done similar scripts, but this one is _very_ vt100-heavy.
: I don't know if I can 'input' for a set of text.
: Instead of a character string, like 8005551212, I get cursor position
: escapes around each character, at least that's what it looks like in a log
: session.
:
: I've been doing the logging from a K95 session, but I want to script it
: from ckermit 7, unix, and ignore the screen positioning stuff.
:
: Does 'input' ignore escape sequences for the TERM type that kermit is
: using, or am I going to have to look for the full string?
:
No, INPUT sees all characters that come in (except NUL), so you would actually
match against escape sequences. I'd recommend you begin by finding out how
to tell when the screen is completely painted. Then:
1. CLEAR INPUT
Clear the INPUT buffer (and the \v(input) variable).
2. OUTPUT xxx
Where xxx is whatever you would type to make the thing put up
a screen.
3. INPUT nn zzz
Where nn is an upper bound on the number of seconds to wait for the
screen to be completed, and zzz is some sequence you can use to
identify when the painting is complete.
At this point you have the whole screen in the \v(input) variable, or,
more precisely, the sequence of characters that was sent to the terminal to
make it paint the screen -- escape sequences and all.
Now you can use string functions to parse it, as in the "modemtest" sample
script in our new script library:
http://www.columbia.edu/kermit/ckscripts.html
Doing it this way ensures you don't lose stuff and it also frees you from
dependence on the order in which the fields arrive. Just search for the
appropriate tag (which in this case might be a CUP escape sequence) and then
extract the following string. For example, suppose you're looking for a
10-digit phone number at cursor position [10,20] (row,column). The escape
sequence would be <ESC>[10;20H, so to extract the data you might do
something like this (in C-Kermit 7.0 syntax)(*):
.\%x ::= \findex(\27[10;20H,\v(input)) + 8 ; Find CUP[10,20]
.\%s := \fsubstr(\v(input),\%x,10) ; Get 10 chars after it
If you were using Kermit 95, you could take advantage of its built-in
HLLAPI-like "screen scraping" functions, which are used *after* the terminal
emulator has formatted the screen. In this case you could get the same
effect with:
\fscrstr(ny,nx,n1)
ny = integer.
nx = integer.
n1 = integer.
Returns string:
The string at Terminal-screen coordinates (nx,ny), length n1,
blanks included.
In this case: .\%s := \fscrstr(20,10,10)
The screen-scraping approach is ex-post-facto; it is applied after the data
arrived and treats the screen like a matrix of characters; in this case
escape sequences are long-gone and irrelevant, and you don't reference the
INPUT buffer at all.
In both cases, however, you need to know when it is safe to start looking,
i.e. at what point the screen is completely painted.
(*) For those of you who have not looked at C-Kermit 7.0 yet, the new
assignment operators look like:
.<variablename> <operator> <value>
where:
<variablename> can be any kind of variable
<operator> is:
= To copy the <value> literally.
:= To expand all variables in the value and then copy.
::= Like :=, but then treats the result as an arithmetic expression
and evalulates it.
So:
.\%x ::= \findex(\27[10;20H,\v(input)) + 8
replaces \v(input) by the contents of the INPUT buffer, finds the position
of "\27[10;20H" in it, adds 8 to it, and assigns the result to \%x.
Of course you can do the same in earlier Kermit versions, but the syntax is
a bit more awkward:
assign \%x \feval(\findex(\27[10;20H,\v(input))+8)
- Frank